<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>WebSocket服务器</title>
</head>
<body>
 <h1>aaaaa</h1>
 <script>
     //var wsServer = 'ws://'+document.domain+':9504';
     var wsServer = 'ws://193.112.81.137:9504';
     var websocket = new WebSocket(wsServer);
     websocket.onopen = function (evt) {
         //发服务器发数据
         websocket.send('hello ws');
         console.log("Connected to WebSocket server.");
     };

     websocket.onclose = function (evt) {
         console.log("Disconnected");
     };

     websocket.onmessage = function (evt) {
         console.log('Retrieved data from server: ' + evt.data);
     };

     websocket.onerror = function (evt, e) {
         console.log('Error occured: ' + evt.data);
     };
 </script>
</body>
</html>